package com.lyy.consolidate.homework9;


/**
 * @Author:  GZQ
 * @date:  2024/12/29 21:22
 * @description: 巩固练习9的Person类
 */

public class Person {
    // 属性

    /*
    * 抽取一个父类Person, 将共同属性和方法放到Person类中
    * */

    private String name;
    private char gender;
    private int age;

    // 方法
    public Person(String name, char gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    // play 方法, 把公有的内容写到父类
    public String play() {
        return name + "爱玩";
    }

    // 返回一个基本信息
    /*
    * 姓名：xx
    * 年龄：xx
    * 性别：xx
    * */
    public String basicInfo() {
        return "姓名: " + name  + "\n年龄: " + age + "\n性别: " + gender;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", gender=" + gender +
                ", age=" + age +
                '}';
    }
}
